[#-- 创建商品分页控件的自定义宏，参数：par_total 查询得到的商品总数，par_href 请求路径，par_pagesize 分页大小，par_pageindex 第几页 --]
[#macro ecs_goodspager par_total par_href par_pagesize par_pageindex]
[#assign num=0]
[#if par_total%par_pagesize==0]
	[#assign num=par_total/par_pagesize]
	[#else]
	[#assign num=(par_total/par_pagesize+1)?int]
[/#if]
<form name="selectPageForm"  method="get">
	<div id="pager" class="pagebar">
		<span class="f_l f6" style="margin-right: 10px;">总计 <b>${par_total}</b>
			个记录</span>
		[#if num gt 1]
			[#if (par_pageindex-1) gt 0]
					<a href="${par_href}&index=${par_pageindex-1}" class="prev">上一页</a>	
			[/#if]	
			[#if par_pageindex lt 4]
				[#if num gt 5]
				[#list 1..5 as i]
					[#if i==par_pageindex]
						<span class="page_now">#{par_pageindex}</span>
						[#else]
						<a href="${par_href}&index=${i}">[${i}]</a>
					[/#if]
				[/#list]
				[#else]
				[#list 1..num as i]
					[#if i==par_pageindex]
						<span class="page_now">#{par_pageindex}</span>
						[#else]
						<a href="${par_href}&index=${i}">[${i}]</a>
					[/#if]
				[/#list]									
				[/#if]
			[/#if]	
			[#if par_pageindex gte 4]
				[#if (par_pageindex+2) lte num]
					[#list par_pageindex-2..par_pageindex+2 as i]
						[#if i==par_pageindex]
						<span class="page_now">#{par_pageindex}</span>
						[#else]
						<a href="${par_href}&index=${i}">[${i}]</a>
						[/#if]	
					[/#list]
				[#else]
					[#if num gt 4]
						[#list num-4..num as i]
							[#if i==par_pageindex]
							<span class="page_now">#{par_pageindex}</span>
							[#else]
							<a href="${par_href}&index=${i}">[${i}]</a>
							[/#if]	
						[/#list]
					[#else]
						[#list 1..num as i]
							[#if i==par_pageindex]
							<span class="page_now">#{par_pageindex}</span>
							[#else]
							<a href="${par_href}&index=${i}">[${i}]</a>
							[/#if]	
						[/#list]
					[/#if]
				[/#if]	
			[/#if]
			[#if num gt par_pageindex]
				<a class="next" href="${par_href}&index=${par_pageindex+1}">下一页</a>
			[/#if]
		[/#if]	
	</div>
</form>
[/#macro]
